package State;

import Factory.AgriculturalMachine;

import java.util.Date;

// 空闲状态
public class IdleState implements MachineState {
    private AgriculturalMachine machine;
    private Date startTime;

    public IdleState(AgriculturalMachine machine) {
        this.machine = machine;
        this.startTime = new Date();
    }

    @Override
    public void start() {
        System.out.println("机器开始工作");
        machine.setState(new WorkingState(machine));
    }

    @Override
    public void stop() {
        System.out.println("机器已经处于停止状态");
    }

    @Override
    public void pause() {
        System.out.println("机器处于停止状态，无法暂停");
    }

    @Override
    public void resume() {
        System.out.println("机器处于停止状态，需要先启动");
    }

    @Override
    public void execute() {
        System.out.println("机器处于停止状态，不执行任务");
    }

    @Override
    public String getStateName() {
        return "空闲";
    }

    @Override
    public String getStateDescription() {
        return "机器处于空闲状态，等待指令";
    }

    @Override
    public Date getStateStartTime() {
        return startTime;
    }

    @Override
    public long getStateDuration() {
        return new Date().getTime() - startTime.getTime();
    }

    @Override
    public String toString() {
        return "空闲";
    }
}